import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise'
import 'rxjs/add/operator/map';




@Injectable()
export class MyhttpService {
  goods=[];
  id='';
  count=1;

  constructor(private http:Http,) { }

 getcontacte(){
   return this.http.get('https://www.kalemao.com/limited/get-act-spu-list?page=1&type=underway&act_id=1180')
    .toPromise().then((res)=>{
         return res.json()
     })
  };
  getcontacte1(){
   return this.http.get('https://m.tuniu.com/mapi/home/getProductList?cityCode=2500&moduleId=15638438&currentPage=1&pageLimit=10')
    .toPromise().then((res)=>{
         return res.json()
     })
  };
  // 加入购物车的点击事件
  addgotocart(a){
    //   console.log(a)
    //   if(this.goods.length==0){
    //       return this.goods.unshift(a);
    //   }
    //   for(var i=0;i<this.goods.length;i++){
    //       console.log(this.goods);
    //       if(this.goods[i].id==a.id){
    //            break
    //         }
    //       if(i==this.goods.length-1){
    //             this.goods.unshift(a);
    //         }
    //     }
    //  console.log(this.goods.unshift(a));
     console.log(a)
     this.goods.push(a);
     console.log(this.goods);
      
    }
}
